﻿using System;
using NUnit.Framework;
using Selenium;
using System.Threading;
using System.IO;
using common;

namespace time{
    [TestFixture]
    public class vancl2
    {


        [SetUp]
        public void SetupTest()
        {
            Console.Write("start");
        }

        [TearDown]
        public void TeardownTest()
        {

        }

        [Test]
        public void Login()
        {
            string username = "zz130750@163.com";
            string password = "111111";


            Selenium.ISelenium selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.vancl.com/");
            selenium.Start();
            selenium.Open(@"/");

            selenium.WindowMaximize();

            Thread.Sleep(1000);

            selenium.Click("link=登录");
            selenium.WaitForPageToLoad("30000");
            //Thread.Sleep(2000);

            //vanclUserName vanclPassword
            selenium.Type("id=vanclUserName", username);
            selenium.Type("id=vanclPassword", password);
            selenium.Click("id=vanclLogin");

            Thread.Sleep(2000);
            selenium.Click("id=DropTitle");
            selenium.WaitForPageToLoad("30000");
        }


        [Test]
        public void RegistLogin()
        {
            string username = "zz" + common.NumberHelp.random_number() + "@163.com";
            string password = "111111";

            StreamWriter sw = new StreamWriter("user.txt", true);
            sw.Write(username + " " + password);
            sw.Flush();
            sw.Close();

            Selenium.ISelenium selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.vancl.com/");
            selenium.Start();
            selenium.Open(@"/");
            selenium.WindowMaximize();
            Thread.Sleep(1000);

            selenium.Click("link=注册");
            selenium.WaitForPageToLoad("30000");

            selenium.Type("id=Email", username);
            selenium.Type("id=PassWord", password);
            selenium.Type("id=RexPassWord", password);
            selenium.Type("id=Validate_Code", "a9wev");
            selenium.Click("id=submitRegister");
            Thread.Sleep(20000);
            //Console.ReadLine();


            selenium.Click("link=退出登录");
            selenium.WaitForPageToLoad("30000");


            selenium.Click("link=登录");
            selenium.WaitForPageToLoad("30000");
            //Thread.Sleep(2000);

            //vanclUserName vanclPassword
            selenium.Type("id=vanclUserName", username);
            selenium.Type("id=vanclPassword", password);
            selenium.Click("id=vanclLogin");
            //selenium.WaitForPageToLoad("30000");
            Thread.Sleep(2000);
            
            selenium.Click("id=DropTitle");
            selenium.WaitForPageToLoad("30000");


        }


    }


}


